package se.webbzon.boltzmann.battle.strategy.playerstrategy;

import java.util.Collections;
import java.util.List;

import se.webbzon.boltzmann.battle.battleaction.BattleAction;
import se.webbzon.boltzmann.battle.environment.BattleEnvironment;
import se.webbzon.boltzmann.battle.group.BattleGroup;
import se.webbzon.boltzmann.battle.object.npc.BattleNPC;
import se.webbzon.boltzmann.battle.round.BattleRound;
import se.webbzon.boltzmann.battle.strategy.AbstractStrategy;
import se.webbzon.boltzmann.player.Player;
import se.webbzon.oschi01.worldarea.WorldArea;

public class PlayerStrategy extends AbstractStrategy {
	
	// The battle environment in which the player strategy is performed
	private final BattleEnvironment benv;
	
	// The player associated to this player strategy
	private final Player player; 
	
	// The battle round associated to this player strategy
	private BattleRound round;
	
	// A list of all the participating battle groups
	private List<BattleGroup> all;
	
	// The caster (owner) of this player strategy
	private BattleNPC caster;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public PlayerStrategy(BattleEnvironment benv, Player player) {
		this.benv = benv;
		this.player = player;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override public void onBegin(	BattleRound round, WorldArea world,
									List<BattleGroup> all, BattleNPC caster) {
		this.round = round;
		this.all = all;
		this.caster = caster;
		PlayerStrategyHud hud = 
				new PlayerStrategyHud(this,benv.getLayout());
		world.createInstance(hud);
	}
	
	/** Returns the battle environment in which the strategy was created. **/
	public BattleEnvironment getEnvironment() {
		return benv;
	}
	
	/** Returns the player associated to this player strategy. **/
	public Player getPlayer() {
		return player;
	}
	
	/** Returns the battle round associated to this player strategy. This method
	 * should only be called after the strategy has begun. **/
	public BattleRound getBattleRound() {
		return round;
	}
	
	/** Returns an unmodifiable list of all the participating battle groups. 
	 * This method should only be called after the strategy has begun. **/
	public List<BattleGroup> getBattleGroups() {
		return Collections.unmodifiableList(all);
	}
	
	/** Returns the caster (owner) of this player strategy. This method
	 * should only be called after the strategy has begun. **/
	public BattleNPC getCaster() {
		return caster;
	}
	
	@Override public void notifyListeners(BattleAction battleAction) {
		super.notifyListeners(battleAction);
	}

}
